Skip to content

feat(ourlogs): Add auto-refresh to logs #94887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025
Merged

Conversation

k-fish
Copy link
Member

@k-fish k-fish commented Jul 3, 2025

Summary

This adds an auto-refresh toggle behind the 'ourlogs-live-refresh' flag.

Auto-refresh can be enabled with filters so long as the sort is by time and descending. It works on 5 second polling, with a virtual time using RAF to emulate streaming. Filters are applied so data is queried in a ~30s second window behind our ingest delay.

Auto-refresh will automatically disable itself under the following conditions:

  • You've hit a rate limit consistently over 3 polls (>1k logs/s)
  • You've hit an api error for any reason
  • You've hit the absolute timeout cap (10 minutes), you can re-enable it if you're actively using it
  • You change sort / filter etc.

A subsequent PR will contain changes for the graph updates.

Other

  • Added some memos and callbacks for performance reasons since the virtual timestamp updates fairly quickly
  • Modified delayed data to follow already set delay in graphs (will be needed in the next PR)

@k-fish k-fish requested a review from a team as a code owner July 3, 2025 20:12
@k-fish k-fish requested a review from colin-sentry July 3, 2025 20:12
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 3, 2025
This adds an auto-refresh toggle behind the 'ourlogs-live-refresh' flag.

Auto-refresh can be enabled with filters so long as the sort is by time and descending. It works on 5 second polling, with a virtual time using RAF to emulate streaming. Filters are applied so data is queried in a ~30s second window behind our ingest delay.

Auto-refresh will automatically disable itself under the following conditions:
- You've hit a rate limit consistently over 3 polls (>1k logs/s)
- You've hit an api error for any reason
- You've hit the absolute timeout cap (10 minutes), you can re-enable it if you're actively using it
- You change sort / filter etc.
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Time Sort Check Fails for Descending Order

The checkSortIsTimeBasedDescending function incorrectly checks if any sort is descending, rather than verifying that the time-based sort (obtained from getTimeBasedSortBy) is specifically descending. This can lead to auto-refresh being enabled when the time-based sort is ascending, causing incorrect behavior.

static/app/views/explore/logs/utils.tsx#L198-L204

export function checkSortIsTimeBasedDescending(sortBys: Sort[]) {
return (
getTimeBasedSortBy(sortBys) !== undefined &&
sortBys.some(sortBy => sortBy.kind === 'desc')
);
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Copy link
Contributor

@colin-sentry colin-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah really nice work here

@k-fish k-fish merged commit 121e9a2 into master Jul 7, 2025
46 checks passed
@k-fish k-fish deleted the feat/ourlogs/auto-refresh-base branch July 7, 2025 19:08
);
}, [data]);

// We setup a RAF loop to update the virtual timestamp smoothly to emulate real-time streaming.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have a throttled RAF if we detect bad hardware or older browsers somehow. Maybe do 30fps?

Would be nice to have some stats (send logs?) to track metrics on this.


const refreshCallback = useRef(() => {}); // Since the interval fetches data, it's an infinite dependency loop.
const sortBysString = JSON.stringify(sortBys);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably useMemo this.

Copy link

sentry-io bot commented Jul 11, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

andrewshie-sentry pushed a commit that referenced this pull request Jul 14, 2025
### Summary
This adds an auto-refresh toggle behind the 'ourlogs-live-refresh' flag.

Auto-refresh can be enabled with filters so long as the sort is by time
and descending. It works on 5 second polling, with a virtual time using
RAF to emulate streaming. Filters are applied so data is queried in a
~30s second window behind our ingest delay.

Auto-refresh will automatically disable itself under the following
conditions:
- You've hit a rate limit consistently over 3 polls (>1k logs/s)
- You've hit an api error for any reason
- You've hit the absolute timeout cap (10 minutes), you can re-enable it
if you're actively using it
- You change sort / filter etc.

A subsequent PR will contain changes for the graph updates.

#### Other
- Added some memos and callbacks for performance reasons since the
virtual timestamp updates fairly quickly
- Modified delayed data to follow already set delay in graphs (will be
needed in the next PR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants